package com.zhuss.aop;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;

import com.zhuss.common.ResponseSucc;

@Aspect
@EnableWebMvc
@ControllerAdvice("com.zhuss.controller")
public class ResponseHelper {
	
	@ResponseBody
	@AfterReturning(value = "execution(* com.zhuss.controller.*.*(..))", returning = "result")
	public Object handler(JoinPoint joinPoint, Object result) {
		if (result instanceof ModelAndView || result instanceof ResponseSucc) {
			return result;
		}
		return new ResponseSucc(result);
	}

	
}
